[contents] [prev] [next] [top] [bottom] (5 out of 17)

System Objects

ScriptX provides several objects, created at start-up, that serve as system constants. Table 2-2 describes those objects.

Table 2-2: System objects

Object

Use

true, false

The true and false objects are the two instances of the Boolean class. If true and false are coerced to a Number class, true = 1 and false = 0, so that true > false.

undefined

Equivalent to NULL in other languages; undefined should be used to mean "has no value."

unsupplied

The value assigned to any keyword arguments that were not given explicit values when the function or method was called. Keyword arguments to functions are described in Chapter 5.

empty

Used by functions that operate on collections such as arrays to indicate "element asked for was not found." Do not use empty to mean undefined; use undefined instead. See page 159 for more information about the empty object.

OK

Used by functions that have specific side effects and no relevant return value (similar to functions in C that return void). Functions that return OK should always return OK regardless of the outcome of the function (unless the function reports an exception and the thread it is running in dies). See Chapter 5 for more information about functions and threads. See Chapter 8 for more information about exceptions.

You may be accustomed to languages where certain functions, like void functions in C and C++, return no value. ScriptX is a language of expressions, a language where every expression returns a value. That return value is always an object. Think of a system object as a pointer to some fixed location in memory. A system object is simply a value that is the outcome of so many ScriptX expressions that it has been predefined by the system. All such values are defined as objects, providing completeness to the ScriptX object system.

You can use system objects in your own scripts. Be careful to use them exactly as they are defined in Table 2-2, so that the classes and objects you create can work with other classes and objects.


This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.

Copyright 1996 Apple Computer, Inc. All Rights Reserved.